﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace XNADota.ContentPipeline.Terrain
{
    [ContentSerializerRuntimeType("XNADota.Terrain.VertexInfo, XNADota")]
    public class VertexInfoContent
    {
        public float GroundHeight;
        public Vector3 Position; // 2 bytes
        public int WaterLevel;   // 2 bytes
        public byte Flags; // 0.5 byte
        public byte TextureId; // 0.5 byte
        public byte TextureDetail; // 1 byte
        public byte CliffTextureType; // 0.5 byte
        public byte LayerHeight; // 0.5 byte

        public VertexInfoContent(WCLoader Loader)
        {
            GroundHeight = Position.Y = Loader.ReadInt8() + 256 * Loader.ReadInt8();
            WaterLevel = Loader.ReadInt8() + 256 * Loader.ReadInt8();

            byte word = (Byte)Loader.ReadByte();
            Flags = (Byte)((word & 0xf0) >> 4);
            TextureId = (Byte)(word & 0x0f);

            TextureDetail = Loader.ReadByte();

            word = Loader.ReadByte();
            CliffTextureType = (Byte)((word & 0xf0) >> 4);
            LayerHeight = (Byte)(word & 0x0f);
        }
    }
}
